package jinyilw.swing.visuals;

import jinyilw.common.TextTools;
import jinyilw.swing.visuals.text.RTextArea;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.border.EmptyBorder;
import java.awt.Font;
import java.io.File;

public class TextAreaDialog extends JDialog
{
	private static final long serialVersionUID = -1832324494312288184L;
	private RTextArea textArea;

	public TextAreaDialog(JFrame owner, File f)
	{
		this(owner, f, false);
	}

	public TextAreaDialog(JFrame owner, File f, boolean modal)
	{
		super(owner, modal);
		initUI();
		textArea.setText(TextTools.readUTF8TxtFile(f));
		textArea.setEditable(false);
		textArea.setCaretPosition(0);
	}

	private void initUI()
	{
		textArea = new RTextArea();
		// textArea.setLineWrap(true);
		setContentPane(textArea.getScrollPane());
		// getContentPane().add(textArea.getScrollPane());
		textArea.setBorder(new EmptyBorder(5, 5, 5, 5));
		// getContentPane().add(new JScrollPane(textArea));
	}

	public void setTextFont(Font font)
	{
		textArea.setFont(font);
	}
}
